﻿@model Mantenimiento.Models.PLANTILLA
@{
    ViewBag.Title = "Registrar Plantilla de Mantenimiento";
}

<h2>Registrar Plantilla de Mantenimiento</h2>
 <script type="text/javascript">
        $(document).ready(function () {
 
            $.ajaxSetup({ cache: false });
           
            $("#openDialog").live("click", function (e) {
                e.preventDefault();
                var url = $(this).attr('href');
 
                $("#dialog-edit").dialog({
                    title: 'Agregar Actividad',
                    autoOpen: false,
                    resizable: false,
                    height: 355,
                    width: 400,
                    show: { effect: 'drop', direction: "up" },
                    modal: true,
                    draggable: true,
                    open: function (event, ui) {
                        $(this).load(url);
                    },
                    close: function (event, ui) {
                        $(this).dialog('close');
                    }
                });
 
                $("#dialog-edit").dialog('open');
                return false;
            });
 
            $(".editDialog").live("click", function (e) {
                var url = $(this).attr('href');
                $("#dialog-edit").dialog({
                    title: 'Editar Actividad',
                    autoOpen: false,
                    resizable: false,
                    height: 355,
                    width: 400,
                    show: { effect: 'drop', direction: "up" },
                    modal: true,
                    draggable: true,
                    open: function (event, ui) {
                        $(this).load(url);
 
                    },
                    close: function (event, ui) {
                        $(this).dialog('close');
                    }
                });
 
                $("#dialog-edit").dialog('open');
                return false;
            });
 
            $(".confirmDialog").live("click", function (e) {
 
                var url = $(this).attr('href');
                $("#dialog-confirm").dialog({
                    title: 'Mensaje de Confirmación',
                    autoOpen: false,
                    resizable: false,
                    height: 170,
                    width: 350,
                    show: { effect: 'drop', direction: "up" },
                    modal: true,
                    draggable: true,
                    buttons: {
                        "OK": function () {
                            $(this).load(url);
                            window.location = "/Plantilla/Create";
                            window.location = "/Plantilla/Create";
                            //$(this).dialog("close");                            
                        },
                        "Cancel": function () {
                            $(this).dialog("close");
 
                        }
                    }
                });
                $("#dialog-confirm").dialog("open");
                return false;
            });
 
            $("#btnSave").live("click", function (e) {
                $("#dialog-edit").dialog('close');
            });

            $("#btnUpdate").live("click", function (e) {
                $("#dialog-edit").dialog('close');

            });

            $("#btncancel").live("click", function (e) {

                $("#dialog-edit").dialog('close');
 
            });
        });  
    </script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)

    <div id="dialog-confirm" style="display: none">
        <p>
            <span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>
            ¿Está seguro de eliminar la actividad?
        </p>
    </div>
    <div id="dialog-edit" style="display: none">
    </div>
    <div id="dialog-view" style="display: none">
    </div>
    
    <fieldset>
        <legend>PLANTILLA</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.DESCRIPCION)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.DESCRIPCION)
            @Html.ValidationMessageFor(model => model.DESCRIPCION)
        </div>         
        <div class="editor-label">
            @Html.LabelFor(model => model.REGIMEN)
        </div>
        <div class="editor-field">
            Por Tiempo @Html.RadioButtonFor(model => model.REGIMEN, "1", new { @style = "width: 60px" })
            Por Recorrido @Html.RadioButtonFor(model => model.REGIMEN, "2", new { @style = "width: 60px" })
        </div>

        <p>
            Lista de Actividades @Html.ActionLink("Nueva Actividad", "AddEditActividad", "Plantilla", new { id = Model.PLANTILLA_ID }, new { @id = "openDialog", @class = "buttonClass" })
        </p> 

        @{ Html.RenderPartial("ListActividad", Model.PlantillaDetalle); }
                        
        <p>
            @Html.ActionLink("Cancelar", "Index", new {}, new { @class = "buttonClass"}) <input type="submit" value="Registrar" />
        </p>
    </fieldset>
}

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    @Scripts.Render("~/bundles/jqueryui")
}
